package demo

import (
	"fmt"

	"github.com/gin-gonic/gin"
)

func RequestQuery() {
	Router := gin.Default()

	Router.GET("/query", func(c *gin.Context) {
		name := c.Query("name")
		age := c.DefaultQuery("age", "18")
		key := c.QueryArray("key")
		fmt.Println(name, age, key)
	})

	//动态参数
	Router.GET("/query/:id", func(c *gin.Context) {
		id := c.Param("id")
		fmt.Println(id)
	})
	Router.GET("/query/:id/:name", func(c *gin.Context) {
		id := c.Param("id")
		name := c.Param("name")
		fmt.Println(id, name)
	})

	Router.Run(":8080")
}
